<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html40/strict.dtd">
<HTML>
<HEAD>
<meta name="viewport" content="width=device-width, target-densitydpi=device-dpi" />
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>
	var maxWidth;
	var maxHeigth;
   function showMsg(width,heigth){
      maxWidth=width;
	  maxHeigth=heigth;
	  alert(maxWidth+"  showMsg   "+maxHeigth);
   }
   function showMsgInAndroid(){
      myjs.showMsg('hello in android!');
   }
   
function setImgSize(imgID)
{
	alert(maxWidth+"  imgID   "+maxHeigth);
    var img = document.images[imgID];
    if(maxWidth < 1)
    {
        if(img.height > maxHeight)
        {
            img.height = maxHeight;
        }
        return true;
    }
    if(maxHeight < 1)
    {
        if(img.width > maxWidth)
        {
            img.width = maxWidth;
        }
        return true;
    }
    if(img.height > maxHeight || img.width > maxWidth)
    {
        if((img.height / maxHeight) > (img.width / maxWidth))
        {
            img.height = maxHeight;
        }
        else
        {
            img.width = maxWidth;
        }
        return true;
    }
}
</script>
</HEAD>
<BODY>
<button id='btntest' onclick='showMsgInAndroid()'>调用android方法</button></br>
<img alt="" id="img1" onload="setImgSize('img1');"  src="http://img.poco.cn/photo/20060602/972374149620060602140117_1.jpg" /> 
</BODY>
</HTML>